﻿<UserControl x:Class="SubtitleMatcher.Client.SubsMatchProvidersModule.Views.SubsMatchProvidersView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:SubtitleMatcher.Client.SubsMatchProvidersModule.Views"
             mc:Ignorable="d" 
             >
    <UserControl.Resources>
        <SolidColorBrush x:Key="ItemBrush" Color="Transparent" />
        <SolidColorBrush x:Key="SelectedItemBrush" Color="LightBlue" />
        <SolidColorBrush x:Key="HoverItemBrush" Color="Azure" />
        <Style x:Key="RoundedItem" TargetType="ListBoxItem">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ListBoxItem">
                        <Border Name="ItemBorder" CornerRadius="10" BorderBrush="Black" BorderThickness="1" Margin="1" Background="{StaticResource ItemBrush}">
                            <ContentPresenter />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter TargetName="ItemBorder" Property="Background" Value="{StaticResource SelectedItemBrush}" />
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsMouseOver" Value="True" />
                                    <Condition Property="IsSelected" Value="False" />
                                </MultiTrigger.Conditions>
                                <Setter TargetName="ItemBorder" Property="Background" Value="{StaticResource HoverItemBrush}" />
                            </MultiTrigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <StackPanel>
        <TextBlock Text="Choose your"  />
        <TextBlock Text="Search provider:"  />
        <ListBox ItemsSource="{Binding Path=SubtitleMatcherProviders}" SelectedItem="{Binding Path=SelectedSubtitleMatcherProvider}" SelectionMode="Single" ItemContainerStyle="{StaticResource RoundedItem}">
        <ListBox.ItemTemplate>
            
            <DataTemplate>
                <Border BorderBrush="Black" BorderThickness="3" CornerRadius="3">
                <StackPanel>

                    <TextBlock Grid.Column="0" Text="{Binding Path=ProviderName}" FontStyle="Oblique" />
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Grid.Column="1" Text="Language:" />
                            <ComboBox Grid.Column="2"  ItemsSource="{Binding SupportedLanguages}" SelectedIndex="0" SelectedValue="{Binding Path=SelectedLanguage,Mode=OneWayToSource}">
                                    <ComboBox.ItemTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding DisplayName}" />
                                        </DataTemplate>
                                    </ComboBox.ItemTemplate>
                                </ComboBox>
                        </StackPanel>
                    </StackPanel>
                </Border>
            </DataTemplate>
        </ListBox.ItemTemplate>

    </ListBox>
    </StackPanel>
</UserControl>
